// define custom error types through IError interface
//      msg() string
//      code() int
// embed the builtin `Error` default implementation

struct PathError {
	Error
	path string
}

fn (err PathError) msg() string {
	return 'Failed to open path: $err.path'
}

fn try_open(path string) ? {
	return IError(PathError{
		path: path
	})
}

fn main() {
	try_open('/tmp') or { panic(err) }
}
